import java.util.Scanner;

/**
 * Created by L.jp
 * Description:
 * User: 86189
 * Date: 2021-10-07
 * Time: 21:28
 */
public class BorrowOperation implements Ioperation {
    @Override
    public void work(BookList bookList) {
        if (bookList.getSize() == 0) {
            System.out.println("书库无书，无法进行借阅");
            return;
        }
        Scanner reader = new Scanner(System.in);
        String name;
        System.out.print("请输入你要借阅的书名：");
        name = reader.nextLine();
        for (int i = 0; i < bookList.getSize(); i++) {
            if (name.equals(bookList.getBook(i).getName())) {
                if (bookList.getBook(i).isLent() == false) {
                    bookList.getBook(i).setLent(true);
                    System.out.println("借阅成功");
                } else {
                    System.out.println("该书已被他人借阅，借阅失败");
                }
                return;
            }
        }
        System.out.println("未查询到该书，借阅失败");
    }
}


